package view;

import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.AbstractTableModel;

public class HighscoreTable extends AbstractTableModel implements TableModelListener{
	private static final long serialVersionUID = 1L;
	
	
	private String[] columnNames;
	private Object[][] data; 

	
	public HighscoreTable(String[] columnNames, Object[][] data){
		this.addTableModelListener(this);	
		this.data = data;
		this.columnNames = columnNames;
	}
	
	
	public int getColumnCount() {
		return columnNames.length;
	}
	
	
	public int getRowCount() {
        return data.length;
    }

    public String getColumnName(int col) {
        return columnNames[col];
    }

    public Object getValueAt(int row, int col) {
        return data[row][col];
    }

    public Class getColumnClass(int c) {
        return getValueAt(0, c).getClass();
    }

    public boolean isCellEditable(int row, int col) {

        if (col == 1) {
            return true;
        } else {
            return false;
        }
    }

    public void setValueAt(Object value, int row, int col) {
        data[row][col] = value;
        fireTableCellUpdated(row, col);
    }

	public void tableChanged(TableModelEvent arg0) {
				
	}
		    
}
